﻿using BYSJ.Web.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BYSJ.Model;

namespace BYSJ.Web.Commmend
{
    public class ConvertmModel
    {
        public oneSelf aboutMe(UserSet user)
        {
            oneSelf oneself = new oneSelf();
            oneself.name = user.Name;
            oneself.jointime = string.Format("{0:D}",user.CreatTime).ToString();
            oneself.banji = user.zhuanji;
            oneself.email = user.Email;
            oneself.sgenfen = shenFenpanduan(user.shenfen);
            oneself.zhuanye = user.zhuanye;
            return oneself;
        }


        public List<FileSearch> FileSearch(List<FileMangSet> filedb)
        {
            List<FileSearch> fileview = new List<FileSearch>();
            foreach (var item in filedb)
            {
                FileSearch file = new FileSearch();
                file.name = item.FileName;
                file.filerel = item.FileUrl;
                file.username = item.UserSet.Name;
                file.time = item.FilecreatTime.ToShortDateString().ToString();
                fileview.Add(file);
            }
            return fileview;
        }

        static string shenFenpanduan(int biaoshi)
        {
            if(biaoshi==1)
            {
                return "学生";
            }
            if(biaoshi==2)
            {
                return "老师";
            }
            else
            {
                return "非法用户";
            }
        }
    }
}